package com.ocom.payhandle.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.payconfig.FeeData;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payhandle.dao.IDaoFeeData;
import com.ocom.payhandle.service.FeeDataService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class FeeDataServiceImpl  extends ServiceImpl<IDaoFeeData, FeeData> implements FeeDataService {
    @DataSourceAspect(type = DataSourceEnum.PART_DB, companyId = "comId", isMaster = MasterSlaveEnum.MASTER)
    public Boolean updateFeeStatus(Long comId, String id, String orderNo,Long realMoney) {
        UpdateWrapper<FeeData> update = Wrappers.update();
        update.eq("com_id ", comId);
        update.eq("id ", id);
        update.eq("data_status ", 1);
        update.set("data_status",4);
        update.set("trade_no",orderNo);
        update.set("complete_money",realMoney);
        update.set("fee_time", LocalDateTime.now());
        update.set("update_time", LocalDateTime.now());
        update.set("update_userid", 888);
        return this.update(update);
    }
}
